<template>
  <div>
    <template v-for="v in menuData">
      <el-submenu
        :index="v.name"
        v-if="v.children && v.children.length > 0"
        :key="v.name"
      >
        <template slot="title">
          <i class="el-icon-location"></i>
          <span slot="#title">{{ v.meta.name }}</span>
        </template>
        <el-menu-item-group>
          <my-nav :menuData="v.children"></my-nav>
        </el-menu-item-group>
      </el-submenu>

      <el-menu-item
        :key="v.name"
        :index="v.name"
        @click="gotoRoute(v)"
        v-else-if="v.type != 1 && v.type != 2"
      >
        <i :class="v.meta.icon"></i>
        <span slot="title">{{ v.meta.name }}</span>
      </el-menu-item>
    </template>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
export default {
  name: "my-nav",
  props: {
    menuData: {
      type: Array,
      required: true,
    },
  },
  computed: {
    ...mapState("premissions", ["isCollapse"]),
  },
  methods: {
    gotoRoute(v) {
      this.$router.push({
        name: v.name,
      }); // push(path)  push({name:''})
    },
  },
};
</script>

<style lang="less" scoped>
/deep/ .el-menu-item.is-active {
  background: rgb(77, 188, 255) !important;
  color: #fff !important;
}

/deep/ .el-menu-item {
  height: 48px;
  line-height: 48px;
}

/deep/ .el-menu {
  border: 0;
}

/deep/ .el-menu-item,
.el-submenu__title {
  height: 48px;
  line-height: 48px;
  display: flex;
  align-items: center;
}

/deep/ .el-menu-item-group__title {
  display: none;
}
</style>